package com.hqd.ch03.v51.factory;

import com.hqd.ch03.v51.beans.BeansException;
import com.hqd.ch03.v51.beans.factory.NoSuchBeanDefinitionException;
import com.hqd.ch03.v51.beans.factory.ObjectProvider;
import com.hqd.ch03.v51.core.ResolvableType;

import java.lang.annotation.Annotation;
import java.util.Map;

/**
 * beanFactory拓展，可以遍历整个容器
 */
public interface ListableBeanFactory extends BeanFactory {
    /**
     * 是否包含某个BD
     */
    boolean containsBeanDefinition(String beanName);

    /**
     * 统计所有BD
     */
    int getBeanDefinitionCount();

    /**
     * 获取所有BD名称
     */
    String[] getBeanDefinitionNames();

    /**
     * 获取指定类型的所有BD名称
     */
    String[] getBeanNamesForType(ResolvableType type);

    <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
            throws NoSuchBeanDefinitionException;

    <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;

    String[] getBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit);

    String[] getBeanNamesForType(Class<?> type);

    String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);


    <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
            throws BeansException;

    String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType);

    Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws BeansException;


    <A extends Annotation> A findAnnotationOnBean(
            String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
            throws NoSuchBeanDefinitionException;

    <T> ObjectProvider<T> getBeanProvider(Class<T> requiredType, boolean allowEagerInit);

    <T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType, boolean allowEagerInit);


}

